package net.zoneland.geological.devicedata.service;


import org.apache.log4j.Logger;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

import java.util.UUID;

import net.zoneland.geological.devicedata.entity.Tbl_flow_device_data;
import net.zoneland.geological.devicedata.dao.Tbl_flow_device_dataDao;

import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * tbl_flow_device_data[流水量监测]表操作Serfice实现类

 * 表   名：TBL_FLOW_DEVICE_DATASERVICEIMPL<br/>
 * 注   释：流水量监测<br/>
 * 作   者：李义<br/>
 * 日   期：2017-06-06 09:46:11
**/
@Service("tbl_flow_device_dataService")
public class Tbl_flow_device_dataServiceImpl implements Tbl_flow_device_dataServiceI { 

	public static Logger logger = Logger.getLogger(Tbl_flow_device_dataServiceImpl.class);

	/**
	 * 自动注入DAO对象
	**/
	@Autowired
	private Tbl_flow_device_dataDao tbl_flow_device_dataDao;

	/**
	 * 新增或者更新数据方法接口
	**/
	@Override
	public Tbl_flow_device_data addOrUpdate( Tbl_flow_device_data tbl_flow_device_data )  throws Exception{
		if ( tbl_flow_device_data == null ) {
			logger.error(Tbl_flow_device_data.class.getName() + "对象参数信息为NULL，addOrUpdate方法无法继续！");
			return tbl_flow_device_data;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		if( tbl_flow_device_data.getId() ==null || "".equals( tbl_flow_device_data.getId().trim() ) ){
			map.put( "id", "0000-0000-0000-0000" );
		}else{
			map.put( "id", tbl_flow_device_data.getId() );
		}
		List<Tbl_flow_device_data> list  = tbl_flow_device_dataDao.getList(map);
		if( list != null && !list.isEmpty() ){
			tbl_flow_device_dataDao.edit( tbl_flow_device_data );
			return tbl_flow_device_data;
		}else{
			if( tbl_flow_device_data.getId() ==null || tbl_flow_device_data.getId().trim().isEmpty() ){
				tbl_flow_device_data.setId( UUID.randomUUID() + "" );
		    }
			tbl_flow_device_dataDao.add( tbl_flow_device_data );
			return tbl_flow_device_data;
		}
	}
	/**
	 * 新增数据方法实现
	**/
	@Override
	public boolean add(Tbl_flow_device_data tbl_flow_device_data) throws Exception{
		tbl_flow_device_dataDao.add( tbl_flow_device_data );
		return true;
	}
	/**
	 * 更新数据方法实现
	**/
	@Override
	public boolean update(Tbl_flow_device_data tbl_flow_device_data) throws Exception{
		tbl_flow_device_dataDao.edit( tbl_flow_device_data );
		return true;
	}
	/**
	 * 查询数据方法实现
	**/
	@Override
	public Tbl_flow_device_data get( Map<String, Object> map ) throws Exception{
		return tbl_flow_device_dataDao.get( map );
	}
	/**
	 * 查询数据方法实现（列表）
	**/
	@Override
	public List<Tbl_flow_device_data> getList(Map<String, Object> map) throws Exception{ 
		return tbl_flow_device_dataDao.getList( map );
	}
	
	/**
	 * 查询数据总数方法实现
	**/
	@Override
	public int getListCount(Map<String, Object> map) throws Exception{ 
		return tbl_flow_device_dataDao.getListCount( map );
	}
	
	/**
	 * 数据删除方法实现
	**/
	@Override
	public boolean delete(Map<String, Object> map) throws Exception{ 
		tbl_flow_device_dataDao.delete( map );
		return true;
	}
	
}
